import logging

from requests import Session

from config import HOST


class RechargeApi:
    def __init__(self, session: Session):
        self.__session = session

    def captcha_code_api(self, random: str):
        logging.info(F"图片验证码请求接口 / 请求方法: get / 请求url: {HOST}/common/public/verifycode/{str(random)}")
        return self.__session.get(HOST + F"/common/public/verifycode/{str(random)}")

    def recharge_api(self, amount, vali_code, payment_type="chinapnrTrust", form_str="reForm"):
        data = {"paymentType": payment_type, "amount": amount, "formStr": form_str, "valicode": vali_code}
        logging.info(F"后台充值接口 / 请求方法: post / 请求url: {HOST}/trust/trust/recharge / 请求数据{data}")
        return self.__session.post(HOST + "/trust/trust/recharge", data=data)

    def tripartite_recharge_api(self, url, data):
        logging.info(F"三方充值接口 / 请求方法: post / 请求url: {url} / 请求数据{data}")
        return self.__session.post(url, data=data)
